package com.wave.service;

import com.alibaba.fastjson.JSONObject;
import com.wave.entity.Auth;
import com.wave.mapper.AuthMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuthService {

    @Autowired
    private AuthMapper authMapper;

    public int createAuth(Auth auth){
        return authMapper.createAuth(auth);
    }

    public String getDepartmentId(String department){
        return authMapper.getDepartmentId(department);
    }
    public String getDepartmentName(String department){
        return authMapper.getDepartmentId(department);
    }

    public String getQuarterId(String quarter){
        return authMapper.getQuarterId(quarter);
    }
    public String getQuarterName(String quarter){
        return authMapper.getQuarterId(quarter);
    }

    public void deleteOld(){
        authMapper.deleteOld();
    }

    public JSONObject getAuthList(int pageNum, int pageSize, String aName, String aId, String aDepartments, String aQuarter, String aIdentity) {
        int pageStart = (pageNum - 1) * pageSize; //加载起始
        JSONObject authList = new JSONObject();
        List<Auth> list = authMapper.getAuthList(pageStart, pageSize, aName, aId, aDepartments, aQuarter, aIdentity);
        int total = authMapper.getAuthNum(aName, aId, aDepartments, aQuarter, aIdentity);
        authList.put("authList", list);
        authList.put("total", total);
        return authList;
    }
    public List<Auth> list() {
        return authMapper.list();
    }
    public int delete(int id) {
        return authMapper.delete(id);
    }
}
